package com.bird.component.ddd.model.entity

import com.bird.component.ddd.model.enums.EntityChangeStatus
import java.time.LocalDateTime

open class BaseEntity(
    /**
     * 主键
     */
    var id: Long? = null
) {
    var changeStatus = EntityChangeStatus.UN_CHANGE
    /**
     * 创建时
     */
    var createTime: LocalDateTime? = null
    /**
     * 更新时间
     */
    var updateTime: LocalDateTime? = null
    /**
     * 创建人
     */
    var createBy: Long? = null
    /**
     * 更新人
     */
    var updateBy: Long? = null

    fun toNew() {
        this.changeStatus = EntityChangeStatus.ADD
    }

    fun toUpdate() {
        this.changeStatus = EntityChangeStatus.UPDATE
    }

    fun toDelete() {
        this.changeStatus = EntityChangeStatus.DELETE
    }

    fun toUnChange() {
        this.changeStatus = EntityChangeStatus.UN_CHANGE
    }

}